class Food{
    foodElement: HTMLDivElement;

    constructor(){
        this.foodElement = <HTMLDivElement>document.querySelector(".food")
    }
    // this.X获取食物X坐标
    get X():number{
        return this.foodElement.offsetLeft
    }
    // this.Y获取食物Y坐标
    get Y():number{
        return this.foodElement.offsetTop
    }
    /**
     * 随机生成x, y坐标，改变食物位置
     */
    change(){
        let x = Math.floor(Math.random() * 30) * 20
        let y = Math.floor(Math.random() * 30) * 20
        this.foodElement.style.left = x + "px"
        this.foodElement.style.top = y + "px"
    }
}

export default Food